package com.elock.entity;

import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.elock.base.core.entity.BaseEntity;

/**
 * Entity - 系统参数
 * @author 仁德
 */
@Entity
@Table(name = "system_parameter", uniqueConstraints = {
		@UniqueConstraint(columnNames = { "name", "companyInfoId" }) })
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "system_parameter_sequence")
public class SystemParameter extends BaseEntity {

	private static final long serialVersionUID = 914140705533030444L;

	/** 参数名称 */
	private String name;

	/** 值 */
	private String value;

	/** 备注 */
	private String remark;

	/** 参数编码 */
	private String code;

	/** 是否可修改 */
	private Boolean isModify;

	/** 唯一标识 UUID */
	private String uniqueIdentify;

	/** 获取参数名称 */
	@Column(nullable = false)
	public String getName() {
		return name;
	}

	/** 设置参数名称 */
	public void setName(String name) {
		this.name = name;
	}

	/** 获取值 */
	@Column(nullable = false)
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	/** 获取备注 */
	public String getRemark() {
		return remark;
	}

	/** 设置备注 */
	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Boolean getIsModify() {
		return isModify;
	}

	public void setIsModify(Boolean isModify) {
		this.isModify = isModify;
	}

	/**
	 * 获取 唯一标识 UUID
	 * 
	 * @return uniqueIdentify
	 */
	public String getUniqueIdentify() {
		return uniqueIdentify;
	}

	/**
	 * 设置 唯一标识 UUID
	 * 
	 * @param uniqueIdentify
	 *            唯一标识 UUID
	 */
	public void setUniqueIdentify(String uniqueIdentify) {
		this.uniqueIdentify = uniqueIdentify;
	}

	/**
	 * 持久化前
	 */
	@PrePersist
	public void prePersist() {
		if (getUniqueIdentify() == null) {
			setUniqueIdentify(UUID.randomUUID().toString());
		}
	}
}
